package com.wdzl.dao.impl;

import com.mysql.cj.protocol.ResultBuilder;
import com.wdzl.dao.IuserDao;
import com.wdzl.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class UserDao implements IuserDao {
    private final JdbcTemplate jdbcTemplate;

    public UserDao(JdbcTemplate jdbcTemplate) {
        this.jdbcTemplate = jdbcTemplate;
    }

    @Override
    public String select(User user) {
        String sql="select(select password from user where username=?)";
        return jdbcTemplate.queryForObject (sql,String.class, user.getUsername ());
    }

    @Override
    public void insert(User user) {
String sql="insert into user value(null,?,?)";
jdbcTemplate.update (sql,user.getUsername (),user.getPassword ());
    }
}
